package com.learning.dubbo.service.validation.api;


import com.google.common.base.MoreObjects;

import javax.validation.constraints.Future;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * ClassName: ValidationParameter
 * Description:
 * Date: 2020/7/1 21:19 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public class ValidationParameter implements Serializable {
    private static final long serialVersionUID = 7898113898837209568L;

    /**
     * 不允许为空
     * 长度或大小范围
     */
    @NotNull
    @Size(min = 1, max = 20)
    private String name;

    /**
     * 保存时不允许为空，更新时允许为空 ，表示不更新该字段
     */
    @NotNull(groups = ValidationService.Save.class)
    private String email;

    /**
     * // 最小值
     * // 最大值
     */
    @Min(18)
    @Max(100)
    private int age;

    /**
     * // 必须为一个过去的时间
     */
    @Past
    private Date loginDate;

    /**
     * // 必须为一个未来的时间
     */
    @Future
    private Date expiryDate;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public Date getExpiryDate() {
        return expiryDate;
    }

    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("name", name)
                .add("email", email)
                .add("age", age)
                .add("loginDate", loginDate)
                .add("expiryDate", expiryDate)
                .toString();
    }
}
